# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgname=sed
pkgver=4.5
pkgrel=1
pkgdesc="GNU stream editor"
arch=('i686' 'x86_64')
url="https://www.gnu.org/software/sed"
license=('GPL3')
groups=('base' 'base-devel')
depends=('libintl' 'sh')
makedepends=('gettext' 'gettext-devel')
install=sed.install
source=(https://ftp.gnu.org/pub/gnu/sed/${pkgname}-${pkgver}.tar.xz{,.sig}
        sed-4.4-1.src.patch
        sed-4.5-msysize.patch
        sed-4.4-msys-use-text-mode.patch)
sha256sums=('7aad73c8839c2bdadca9476f884d2953cdace9567ecd0d90f9959f229d146b40'
            'SKIP'
            '12525e7bf4a1b57913d4047a2313f9127f29468193c2b583cfdfa128b4141032'
            'a2842a4db4bff151b630ffbaec065869720f5374e69eea394a8b8e9f8fe22b43'
            '5b25526061d61aaecdec464bccc1e1a78d0e0a64dabdd0eea759399f6c92e0a7')

prepare() {
  cd ${srcdir}/${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/sed-4.5-msysize.patch
  patch -p1 -i ${srcdir}/sed-4.4-msys-use-text-mode.patch

  autoreconf -fiv

  patch -p2 -i ${srcdir}/sed-4.4-1.src.patch
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  ./configure --prefix=/usr --build=${CHOST}
  make all html
}

check() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make check
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
  rm -f ${pkgdir}/usr/lib/charset.alias
}
